package com.bjqg.bjqg01.bjqg.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bjqg.bjqg01.bjqg.R;
import com.bjqg.bjqg01.bjqg.adapter.ResultClmcAdapter;
import com.bjqg.bjqg01.bjqg.adapter.ResultGcdmAdapter;
import com.bjqg.bjqg01.bjqg.bean.GcdmBean;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/4/12 0012.
 */

public class ResultGcdmActivity extends BaseActivity implements View.OnClickListener {

    private ImageView goback;
    private TextView toptitle;
    private ImageView select;
    private RecyclerView rvgcdm;
    private ResultGcdmAdapter resultadapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result_gcdm);

        initView();
    }

    private void initView() {
        goback = (ImageView) findViewById(R.id.back);
        toptitle = (TextView) findViewById(R.id.tv_top_title);
        select = (ImageView) findViewById(R.id.select);

        rvgcdm = (RecyclerView) findViewById(R.id.result_gcdm_rv);

        goback.setOnClickListener(this);
        toptitle.setText("选择工程代码");
        select.setVisibility(View.INVISIBLE);

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        rvgcdm.setLayoutManager(layoutManager);

        resultadapter = new ResultGcdmAdapter(R.layout.item_project_information_manage, generateTips());
        rvgcdm.setAdapter(resultadapter);
        resultadapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
//                Toast.makeText(getApplicationContext(),"材料"+position,Toast.LENGTH_SHORT).show();
//                Intent intent = new Intent(getApplicationContext(), ProjectInformationDetailActivity.class);
//                startActivity(intent);
                Intent intent = new Intent();
//                intent.putExtra("gcdm","工程"+position);
                GcdmBean gcdmBean = new GcdmBean("工程名称" + position, "委托单位" + position,
                        "委托人" + position, "委托人电话" + position);
                intent.putExtra("gcdm", gcdmBean);
                setResult(1,intent);
                finish();
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.back:
                finish();
                break;
        }
    }

    private ArrayList<String> generateTips() {
        ArrayList<String> tips = new ArrayList<>();
        for (int i = 0; i < 50; i++) {

            tips.add("材料名称:"+i);
        }

        return tips;
    }
}
